﻿using Mock1G3.BussinessLogic;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mock1G3.BaseEntities;

namespace Mock1G3.UserControl.UCViewHistory
{
    public partial class FourM : System.Web.UI.UserControl
    {
        static int CurrentPage;
        protected void Page_Load(object sender, EventArgs e)
        {
            BindList();

        }

        void BindList()
        {
            PagedDataSource objPage = new PagedDataSource();
            try
            {
                HistoryLogic user = new HistoryLogic();
                DataTable dt = new DataTable();
                Card card = new Card();
                card.CardNo = Session["CardNo"].ToString();
                dt = user.History4m(card);
                if (dt.Rows.Count == 0)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text = "Not have Data!";
                }
                else
                {
                    objPage.DataSource = dt.DefaultView;
                    objPage.AllowPaging = true;
                    objPage.PageSize = 2;
                    objPage.CurrentPageIndex = CurrentPage;
                    btn6.Enabled = !objPage.IsLastPage;
                    btn3.Enabled = !objPage.IsFirstPage;
                    GridView1.DataSource = objPage;
                    GridView1.DataBind();
                    v1.Visible = true;
                    v2.Visible = true;
                    v3.Visible = true;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                objPage = null;
            }
        }
        protected void btn3_Click(object sender, EventArgs e)
        {
            CurrentPage -= 1;
            BindList();
        }
        protected void btn6_Click(object sender, EventArgs e)
        {
            CurrentPage += 1;
            BindList();
        }
        protected void btn4_Click(object sender, EventArgs e)
        {
            Session.RemoveAll();
            Response.Redirect("Validate.aspx");
        }
        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Session.RemoveAll();
            Response.Redirect("Default.aspx");
        }
    }
}